include io.asm

stack segment stack
	dw 128 dup (?)
stack ends

;;======================================================================
data segment
	Head db "Vasilenko Anatoly. Group 111.$"
	Input db "Enter please number: $"
	Output db "Answer: $"
data ends
;;======================================================================

code segment 'code'
	assume ss:stack, ds:data, cs:code
start:
	mov ax,data
	mov ds,ax
	lea dx, Head
	outstr
	newline
	newline
	;;------------------------------------------------------------------
		lea dx, Input;
		outstr;
		
		inint ax;
		mov cx, ax; save number
		mov dx, 0;
		mov bx, 7;
		div bx;
		
		cmp dx, 4;		
		jb short down;
			neg dx;
			add dx, 7;
			add cx, dx;
			jmp answer;
		down:
			sub cx, dx;
		
	answer:	
		lea dx, Output;
		outstr;
		outint cx;
	;;------------------------------------------------------------------

the_end:
	newline;
	newline;
	mov ah,8
	int 21h
    finish
code ends

;;======================================================================
end start 

;;======================================================================
